home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Languages / MPW Oberon 2.1168 / OInterfaces / OSA.mod < prev    next >
Encoding:
Text File  |  1995-08-10  |  54.3 KB  |  1,418 lines  |  [TEXT/MPS ]

  1. (*
  2.      File:        OSA.mod
  3.  
  4.      Contains:    AppleScript Client Interfaces.
  5.  
  6.      Version:    Technology:    AppleScript 1.1
  7.                  Package:    Universal Interfaces 2.0 in “MPW Latest” on ETO #17
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs.applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. *)
  19.  
  20. (*$TAGS-*)
  21. (*$CALLING PASCAL*)
  22. MODULE OSA;
  23.  
  24. IMPORT SYSTEM, Types, Errors, AppleEvents, Components;
  25.  
  26. (* $PUSH*)
  27. (* $ALIGN MAC68K*)
  28. (* $LibExport+*)
  29.  
  30. CONST
  31.     kOSAComponentType*            = LONG("osa ");
  32.  
  33. (* 0x73637074 *)
  34.     kOSAGenericScriptingComponentSubtype* = LONG("scpt");
  35.  
  36. (*    Type of script document files.    *)
  37. (* 0x6f736173 *)
  38.     kOSAFileType*                = LONG("osas");
  39.  
  40. (*
  41.         Suite and event code of the RecordedText event. 
  42.         (See OSAStartRecording, below.)
  43.     *)
  44. (* 0x61736372 *)
  45.     kOSASuite*                    = LONG("ascr");
  46.  
  47. (* 0x72656364 *)
  48.     kOSARecordedText*            = LONG("recd");
  49.  
  50. (* Selector returns boolean *)
  51. (* 0x6d6f6469 *)
  52.     kOSAScriptIsModified*        = LONG("modi");
  53.  
  54. (* Selector returns boolean *)
  55. (* 0x63736372 *)
  56.     kOSAScriptIsTypeCompiledScript* = LONG("cscr");
  57.  
  58. (* Selector returns boolean *)
  59. (* 0x76616c75 *)
  60.     kOSAScriptIsTypeScriptValue*    = LONG("valu");
  61.  
  62. (* Selector returns boolean *)
  63. (* 0x636e7478 *)
  64.     kOSAScriptIsTypeScriptContext* = LONG("cntx");
  65.  
  66. (* Selector returns a AppleEvents.DescType which may be passed to OSACoerceToDesc *)
  67. (* 0x62657374 *)
  68.     kOSAScriptBestType*            = LONG("best");
  69.  
  70. (*
  71.         This selector is used to determine whether a script has source 
  72.         associated with it that when given to OSAGetSource, the call will not
  73.         fail.  The selector returns a boolean.
  74.     *)
  75. (* 0x67737263 *)
  76.     kOSACanGetSource*            = LONG("gsrc");
  77.  
  78.     typeOSADialectInfo*            = LONG("difo");                        (*  0x6469666f   *)
  79.     keyOSADialectName*            = LONG("dnam");                        (*  0x646e616d   *)
  80.     keyOSADialectCode*            = LONG("dcod");                        (*  0x64636f64   *)
  81.     keyOSADialectLangCode*        = LONG("dlcd");                        (*  0x646c6364   *)
  82.     keyOSADialectScriptCode*        = LONG("dscd");
  83.  
  84.     
  85. TYPE
  86.     OSAError* = Components.ComponentResult;
  87.  
  88. (* Under the Open Scripting Architecture all error results are longs *)
  89.     OSAID* = LONGINT;
  90.  
  91. (*
  92.         OSAIDs allow transparent manipulation of scripts associated with
  93.          various scripting systems.
  94.     *)
  95.  
  96. CONST
  97.     kOSANullScript*                = 0;
  98.  
  99. (* No -script constant. *)
  100.     kOSANullMode*                = 0;                            (* sounds better *)
  101.     kOSAModeNull*                = 0;                            (* tastes consistent *)
  102.  
  103. (*
  104.         Some routines take flags that control their execution.  This constant
  105.         declares default mode settings are used.
  106.     *)
  107. TYPE
  108.     OSACreateAppleEventProcPtr* = (*ΔΔ Types.ProcPtr;*) PROCEDURE (theAEEventClass: AppleEvents.AEEventClass; theAEEventID: AppleEvents.AEEventID; (*CONST*)VAR target: AppleEvents.AEAddressDesc; returnID: INTEGER; transactionID: LONGINT; VAR result: AppleEvents.AppleEvent; refCon: LONGINT): Types.OSErr;
  109.     OSACreateAppleEventUPP* = Types.UniversalProcPtr;
  110.  
  111. CONST
  112.     uppOSACreateAppleEventProcInfo* = $000FEFE0; (* PROCEDURE (4 byte param, 4 byte param, 4 byte param, 2 byte param, 4 byte param, 4 byte param, 4 byte param): 2 byte result; *)
  113.  
  114. PROCEDURE NewOSACreateAppleEventProc*(userRoutine: OSACreateAppleEventProcPtr): OSACreateAppleEventUPP;
  115.     (*$IF NOT GENERATINGCFM *)
  116.     INLINE PASCAL $2E9F;
  117.     (*$END*)
  118.  
  119. PROCEDURE CallOSACreateAppleEventProc*(theAEEventClass: AppleEvents.AEEventClass; theAEEventID: AppleEvents.AEEventID; (*CONST*)VAR target: AppleEvents.AEAddressDesc; returnID: INTEGER; transactionID: LONGINT; VAR result: AppleEvents.AppleEvent; refCon: LONGINT; userRoutine: OSACreateAppleEventUPP): Types.OSErr;
  120.     (*$IF NOT GENERATINGCFM*)
  121.     INLINE PASCAL $205F, $4E90;
  122.     (*$END*)
  123. TYPE
  124.     OSASendProcPtr* = (*ΔΔ Types.ProcPtr;*) PROCEDURE ((*CONST*)VAR theAppleEvent: AppleEvents.AppleEvent; VAR reply: AppleEvents.AppleEvent; sendMode: AppleEvents.AESendMode; sendPriority: AppleEvents.AESendPriority; timeOutInTicks: LONGINT; idleProc: AppleEvents.AEIdleUPP; filterProc: AppleEvents.AEFilterUPP; refCon: LONGINT): Types.OSErr;
  125.     OSASendUPP* = Types.UniversalProcPtr;
  126.  
  127. CONST
  128.     uppOSASendProcInfo* = $003FEFE0; (* PROCEDURE (4 byte param, 4 byte param, 4 byte param, 2 byte param, 4 byte param, 4 byte param, 4 byte param, 4 byte param): 2 byte result; *)
  129.  
  130. PROCEDURE NewOSASendProc*(userRoutine: OSASendProcPtr): OSASendUPP;
  131.     (*$IF NOT GENERATINGCFM *)
  132.     INLINE PASCAL $2E9F;
  133.     (*$END*)
  134.  
  135. PROCEDURE CallOSASendProc*((*CONST*)VAR theAppleEvent: AppleEvents.AppleEvent; VAR reply: AppleEvents.AppleEvent; sendMode: AppleEvents.AESendMode; sendPriority: AppleEvents.AESendPriority; timeOutInTicks: LONGINT; idleProc: AppleEvents.AEIdleUPP; filterProc: AppleEvents.AEFilterUPP; refCon: LONGINT; userRoutine: OSASendUPP): Types.OSErr;
  136.     (*$IF NOT GENERATINGCFM*)
  137.     INLINE PASCAL $205F, $4E90;
  138.     (*$END*)
  139. (**************************************************************************
  140.     Standard Script Errors
  141. **************************************************************************
  142.     It is recommended that scripting components use the following set of error
  143.     codes to signal failure when applicable.  This enables applications that
  144.     use the OSA API to deal with some class of script errors in a less than 
  145.     ad hoc manner.  Scripting components are of course encouraged to return
  146.     component-specific errors when these don't apply.
  147. **************************************************************************)
  148. (*        Dynamic errors*:
  149.  
  150.     These errors result from data-dependent conditions and are typically
  151.     signaled at runtime.
  152. *)
  153. (*
  154.         Signaled when a value can't be coerced to the desired type. Similar
  155.           to errOSATypeError except results from coercion.
  156.     *)
  157.  
  158. CONST
  159.     errOSACantCoerce*            = Errors.errAECoercionFail;
  160.  
  161. (* Signaled when an object is not found in a container *)
  162.     errOSACantAccess*            = Errors.errAENoSuchObject;
  163.  
  164. (*
  165.         Signaled when an object cannot be set in a container.  Same as 
  166.           AERegistry error errAEWriteDenied.
  167.     *)
  168.     errOSACantAssign*            = -10006;
  169.  
  170. (*
  171.         Signaled by user scripts or applications when no actual error code
  172.           is to be returned.  Simply means "an error has occurred".  Most useful
  173.           in conjunction with an error message from the application.
  174.     *)
  175.     errOSAGeneralError*            = -2700;
  176.  
  177. (* Signaled when there is an attempt to divide by zero *)
  178.     errOSADivideByZero*            = -2701;
  179.  
  180. (* Signaled when integer or real value is too large to be represented *)
  181.     errOSANumericOverflow*        = -2702;
  182.  
  183. (*
  184.         Signaled when application can't be launched or when it is remote and
  185.           program linking is not enabled.
  186.     *)
  187.     errOSACantLaunch*            = -2703;
  188.  
  189. (* Signaled when an application can't respond to AppleEvents *)
  190.     errOSAAppNotHighLevelEventAware* = -2704;
  191.  
  192. (* Signaled when an application's terminology resource is not readable *)
  193.     errOSACorruptTerminology*    = -2705;
  194.  
  195. (* Signaled when the runtime stack overflows *)
  196.     errOSAStackOverflow*            = -2706;
  197.  
  198. (* Signaled when a runtime internal data structure overflows *)
  199.     errOSAInternalTableOverflow*    = -2707;
  200.  
  201. (*
  202.         Signaled when an intrinsic limitation is exceeded for the size of 
  203.           a value or data structure.
  204.     *)
  205.     errOSADataBlockTooLarge*        = -2708;
  206.  
  207.     errOSACantGetTerminology*    = -2709;
  208.  
  209.     errOSACantCreate*            = -2710;
  210.  
  211. (*        Components.Component-specific dynamic script errors*:
  212.  
  213.     The range -2720 thru -2739 is reserved for component-specific runtime errors.
  214.     (Note that error codes from different scripting components in this range will
  215.     overlap.)
  216. *)
  217. (*        Static errors*:
  218.  
  219.     These errors comprise what are commonly thought of as parse and compile-
  220.     time errors.  However, in a dynamic system (e.g. AppleScript) any or all
  221.     of these may also occur at runtime.
  222. *)
  223. (* Signaled when data was not the right type and coercion is not allowed *)
  224.     errOSATypeError*                = Errors.errAEWrongDataType;
  225.  
  226. (* Signaled when a message was sent to an object that didn't handle it *)
  227.     OSAMessageNotUnderstood*        = Errors.errAEEventNotHandled;
  228.  
  229. (*
  230.         Signaled when a function to be returned doesn't exist.  (Probably only
  231.           useful in languages with first-class functions that distinguish between
  232.           functions and other values (two name spaces). This is different from
  233.           errOSAMessageNotUnderstood, which may be signaled when the method is
  234.           invoked.
  235.     *)
  236.     OSAUndefinedHandler*            = Errors.errAEHandlerNotFound;
  237.  
  238. (* Signaled when a container can never have the requested object *)
  239.     OSAIllegalAccess*            = Errors.errAEAccessorNotFound;
  240.  
  241. (* Signaled when index was out of range. Specialization of errOSACantAccess. *)
  242.     OSAIllegalIndex*                = Errors.errAEIllegalIndex;
  243.  
  244. (* Signaled when a range is screwy. Specialization of errOSACantAccess. *)
  245.     OSAIllegalRange*                = Errors.errAEImpossibleRange;
  246.  
  247. (*
  248.         Signaled when an object can never be set in a container.  Same as 
  249.           AERegistry error errAENotModifiable.
  250.     *)
  251.     OSAIllegalAssign*            = -10003;
  252.  
  253. (*
  254.         Signaled when a syntax error occurs. (e.g. "Syntax error" or
  255.          "<this> can't go after <that>").
  256.     *)
  257.     OSASyntaxError*                = -2740;
  258.  
  259. (*
  260.         Signaled when another form of syntax was expected. (e.g. "expected
  261.           a <type> but found <this>").
  262.     *)
  263.     OSASyntaxTypeError*            = -2741;
  264.  
  265. (* Signaled when a name or number is too long to be parsed *)
  266.     OSATokenTooLong*                = -2742;
  267.  
  268. (*
  269.         Signaled when a parameter is missing for a function invocation.  Note
  270.           that in some languages, this error may occur at runtime.
  271.     *)
  272.     OSAMissingParameter*            = Errors.errAEDescNotFound;
  273.  
  274. (*
  275.         Signaled when function is called with the wrong number of parameters,
  276.           or a parameter pattern cannot be matched.
  277.     *)
  278.     OSAParameterMismatch*        = Errors.errAEWrongNumberArgs;
  279.  
  280. (*
  281.         Signaled when a formal parameter, local variable, or instance variable
  282.           is specified more than once.
  283.     *)
  284.     OSADuplicateParameter*        = -2750;
  285.  
  286. (*
  287.         Signaled when a formal parameter, local variable, or instance variable
  288.           is specified more than once.
  289.     *)
  290.     OSADuplicateProperty*        = -2751;
  291.  
  292. (*
  293.         Signaled when more than one handler is defined with the same name in 
  294.           a scope where the language doesn't allow it.
  295.     *)
  296.     OSADuplicateHandler*            = -2752;
  297.  
  298. (* Signaled when a variable is accessed that has no value *)
  299.     OSAUndefinedVariable*        = -2753;
  300.  
  301. (*
  302.         Signaled when a variable is declared inconsistently in the same scope,
  303.           such as both local and global.
  304.     *)
  305.     OSAInconsistentDeclarations*    = -2754;
  306.  
  307. (*
  308.         Signaled when illegal control flow occurs in an application (no catcher
  309.           for throw, non-lexical loop exit, etc.).
  310.     *)
  311.     OSAControlFlowError*            = -2755;
  312.  
  313. (*        Components.Component-specific static script errors*:
  314.  
  315.     The range -2760 thru -2779 is reserved for component-specific parsing and
  316.     compile-time errors. (Note that error codes from different scripting
  317.     components in this range will overlap.)
  318. *)
  319. (*        Dialect-specific script errors*:
  320.  
  321.     The range -2780 thru -2799 is reserved for dialect specific error codes for
  322.     scripting components that support dialects. (Note that error codes from
  323.     different scripting components in this range will overlap, as well as error
  324.     codes from different dialects in the same scripting component.)
  325. *)
  326. (**************************************************************************
  327.     OSA Interface Descriptions
  328. **************************************************************************
  329.     The OSA Interface is broken down into a required interface, and several
  330.     optional interfaces to support additional functionality.  A given scripting
  331.     component may choose to support only some of the optional interfaces in
  332.     addition to the basic interface.  The OSA Components.Component Flags may be used to 
  333.     query the Components.Component Manager to find a scripting component with a particular
  334.     capability, or determine if a particular scripting component supports a 
  335.     particular capability.
  336. **************************************************************************)
  337. (* OSA Components.Component Flags*: *)
  338.     kOSASupportsCompiling*        = $0002;
  339.     kOSASupportsGetSource*        = $0004;
  340.     kOSASupportsAECoercion*        = $0008;
  341.     kOSASupportsAESending*        = $0010;
  342.     kOSASupportsRecording*        = $0020;
  343.     kOSASupportsConvenience*        = $0040;
  344.     kOSASupportsDialects*        = $0080;
  345.     kOSASupportsEventHandling*    = $0100;
  346.  
  347. (* Components.Component Selectors*: *)
  348.     kOSASelectLoad*                = $0001;
  349.     kOSASelectStore*                = $0002;
  350.     kOSASelectExecute*            = $0003;
  351.     kOSASelectDisplay*            = $0004;
  352.     kOSASelectScriptError*        = $0005;
  353.     kOSASelectDispose*            = $0006;
  354.     kOSASelectSetScriptInfo*        = $0007;
  355.     kOSASelectGetScriptInfo*        = $0008;
  356.     kOSASelectSetActiveProc*        = $0009;
  357.     kOSASelectGetActiveProc*        = $000A;
  358.  
  359. (* Compiling*: *)
  360.     kOSASelectScriptingComponentName* = $0102;
  361.     kOSASelectCompile*            = $0103;
  362.     kOSASelectCopyID*            = $0104;
  363.  
  364. (* GetSource*: *)
  365.     kOSASelectGetSource*            = $0201;
  366.  
  367. (* AECoercion*: *)
  368.     kOSASelectCoerceFromDesc*    = $0301;
  369.     kOSASelectCoerceToDesc*        = $0302;
  370.  
  371. (* AESending*: *)
  372.     kOSASelectSetSendProc*        = $0401;
  373.     kOSASelectGetSendProc*        = $0402;
  374.     kOSASelectSetCreateProc*        = $0403;
  375.     kOSASelectGetCreateProc*        = $0404;
  376.     kOSASelectSetDefaultTarget*    = $0405;
  377.  
  378. (* Recording*: *)
  379.     kOSASelectStartRecording*    = $0501;
  380.     kOSASelectStopRecording*        = $0502;
  381.  
  382. (* Convenience*: *)
  383.     kOSASelectLoadExecute*        = $0601;
  384.     kOSASelectCompileExecute*    = $0602;
  385.     kOSASelectDoScript*            = $0603;
  386.  
  387. (* Dialects*: *)
  388.     kOSASelectSetCurrentDialect*    = $0701;
  389.     kOSASelectGetCurrentDialect*    = $0702;
  390.     kOSASelectAvailableDialects*    = $0703;
  391.     kOSASelectGetDialectInfo*    = $0704;
  392.     kOSASelectAvailableDialectCodeList* = $0705;
  393.  
  394. (* Event Handling*: *)
  395.     kOSASelectSetResumeDispatchProc* = $0801;
  396.     kOSASelectGetResumeDispatchProc* = $0802;
  397.     kOSASelectExecuteEvent*        = $0803;
  398.     kOSASelectDoEvent*            = $0804;
  399.     kOSASelectMakeContext*        = $0805;
  400.  
  401. (* scripting component specific selectors are added beginning with this value  *)
  402.     kOSASelectComponentSpecificStart* = $1001;
  403.  
  404. (*        Mode Flags*:
  405.  
  406.     Warning*: These should not conflict with the AESend mode flags in
  407.     AppleEvents.h, because we may want to use them as OSA mode flags too.
  408. *)
  409. (*
  410.         This mode flag may be passed to OSALoad, OSAStore or OSACompile to
  411.           instruct the scripting component to not retain the "source" of an
  412.           expression.  This will cause the OSAGetSource call to return the error
  413.           errOSASourceNotAvailable if used.  However, some scripting components
  414.           may not retain the source anyway.  This is mainly used when either space
  415.           efficiency is desired, or a script is to be "locked" so that its
  416.           implementation may not be viewed.
  417.     *)
  418.     kOSAModePreventGetSource*    = $00000001;
  419.  
  420. (*
  421.         These mode flags may be passed to OSACompile, OSAExecute, OSALoadExecute
  422.           OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  423.           indicate whether or not the script may interact with the user, switch
  424.           layer or reconnect if necessary.  Any AppleEvents will be sent with the
  425.           corresponding AESend mode supplied.
  426.     *)
  427.     kOSAModeNeverInteract*        = AppleEvents.kAENeverInteract;
  428.     kOSAModeCanInteract*            = AppleEvents.kAECanInteract;
  429.     kOSAModeAlwaysInteract*        = AppleEvents.kAEAlwaysInteract;
  430.     kOSAModeDontReconnect*        = AppleEvents.kAEDontReconnect;
  431.  
  432. (*
  433.         This mode flag may be passed to OSACompile, OSAExecute, OSALoadExecute
  434.           OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  435.           indicate whether or not AppleEvents should be sent with the
  436.           kAECanSwitchLayer mode flag sent or not. NOTE*: This flag is exactly the
  437.           opposite sense of the AppleEvents.AppleEvent flag kAECanSwitchLayer.  This is to
  438.           provide a more convenient default, i.e. not supplying any mode
  439.           (kOSAModeNull) means to send events with kAECanSwitchLayer.  Supplying
  440.           the kOSAModeCantSwitchLayer mode flag will cause AESend to be called
  441.           without kAECanSwitchLayer.
  442.     *)
  443.     kOSAModeCantSwitchLayer*        = $00000040;
  444.  
  445. (*
  446.         This mode flag may be passed to OSACompile, OSAExecute, OSALoadExecute
  447.           OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  448.           indicate whether or not AppleEvents should be sent with the kAEDontRecord
  449.           mode flag sent or not. NOTE*: This flag is exactly the opposite sense of
  450.           the AppleEvents.AppleEvent flag kAEDontRecord.  This is to provide a more convenient
  451.           default, i.e. not supplying any mode (kOSAModeNull) means to send events
  452.           with kAEDontRecord.  Supplying the kOSAModeDoRecord mode flag will 
  453.           cause AESend to be called without kAEDontRecord.
  454.     *)
  455.     kOSAModeDoRecord*            = $00001000;
  456.  
  457. (*
  458.         This is a mode flag for OSACompile that indicates that a context should
  459.           be created as the result of compilation. All handler definitions are
  460.           inserted into the new context, and variables are initialized by
  461.           evaluating their initial values in a null context (i.e. they must be
  462.           constant expressions).
  463.     *)
  464.     kOSAModeCompileIntoContext*    = $00000002;
  465.  
  466. (*
  467.         This is a mode flag for OSACompile that indicates that the previous
  468.           script AIFF.ID (input to OSACompile) should be augmented with any new
  469.           definitions in the sourceData rather than replaced with a new script.
  470.           This means that the previous script AIFF.ID must designate a context.
  471.           The presence of this flag causes the kOSAModeCompileIntoContext flag
  472.           to be implicitly used, causing any new definitions to be initialized
  473.           in a null context.
  474.     *)
  475.     kOSAModeAugmentContext*        = $00000004;
  476.  
  477. (*
  478.         This mode flag may be passed to OSADisplay or OSADoScript to indicate
  479.           that output only need be human-readable, not re-compilable by OSACompile.
  480.           If used, output may be arbitrarily "beautified", e.g. quotes may be left
  481.           off of string values, long lists may have elipses, etc.
  482.     *)
  483.     kOSAModeDisplayForHumans*    = $00000008;
  484.  
  485. (*
  486.         This mode flag may be passed to OSAStore in the case where the scriptID
  487.           is a context.  This causes the context to be saved, but not the context's
  488.           parent context.  When the stored context is loaded back in, the parent
  489.           will be kOSANullScript.
  490.     *)
  491.     kOSAModeDontStoreParent*        = $00010000;
  492.  
  493. (*
  494.         This mode flag may be passed to OSAExecuteEvent to cause the event to
  495.           be dispatched to the direct object of the event. The direct object (or
  496.           subject attribute if the direct object is a non-object specifier) will
  497.           be resolved, and the resulting script object will be the recipient of
  498.           the message. The context argument to OSAExecuteEvent will serve as the
  499.           root of the lookup/resolution process.
  500.     *)
  501.     kOSAModeDispatchToDirectObject* = $00020000;
  502.  
  503. (*
  504.         This mode flag may be passed to OSAExecuteEvent to indicate that
  505.           components do not have to get the data of object specifier arguments.
  506.     *)
  507.     kOSAModeDontGetDataForArguments* = $00040000;
  508.  
  509. (**************************************************************************
  510.     OSA Basic Scripting Interface
  511. **************************************************************************
  512.     Scripting components must at least support the Basic Scripting interface.
  513. **************************************************************************)
  514. (*        Loading and Storing Scripts*:
  515.  
  516.     These routines allow scripts to be loaded and stored in their internal
  517.     (possibly compiled, non-text) representation.
  518. *)
  519. (* Resource type for scripts *)
  520.     kOSAScriptResourceType*        = kOSAGenericScriptingComponentSubtype;
  521.  
  522. (*
  523.         Default type given to OSAStore which creates "generic" loadable script
  524.           data descriptors.
  525.     *)
  526.     typeOSAGenericStorage*        = kOSAScriptResourceType;
  527.  
  528.  
  529. PROCEDURE OSALoad*(scriptingComponent: Components.ComponentInstance; (*CONST*)VAR scriptData: AppleEvents.AEDesc; modeFlags: LONGINT; VAR resultingScriptID: OSAID): OSAError;
  530.     (*$IF NOT GENERATINGCFM*)
  531.     INLINE PASCAL $2F3C, $C, $0001, $7000, $A82A;
  532.     (*$END*)
  533. (*
  534.         OSAComponentFunctionInline(kOSASelectLoad, 12);
  535.     
  536.         Errors*:
  537.             badComponentInstance        invalid scripting component instance
  538.             errOSASystemError
  539.             errOSABadStorageType*:        scriptData not for this scripting component
  540.             errOSACorruptData*:            data seems to be corrupt
  541.             errOSADataFormatObsolete    script data format is no longer supported
  542.             errOSADataFormatTooNew        script data format is from a newer version
  543.         
  544.         ModeFlags*:
  545.             kOSAModePreventGetSource
  546.     *)
  547. PROCEDURE OSAStore*(scriptingComponent: Components.ComponentInstance; scriptID: OSAID; desiredType: AppleEvents.DescType; modeFlags: LONGINT; VAR resultingScriptData: AppleEvents.AEDesc): OSAError;
  548.     (*$IF NOT GENERATINGCFM*)
  549.     INLINE PASCAL $2F3C, $10, $0002, $7000, $A82A;
  550.     (*$END*)
  551. (*
  552.         OSAComponentFunctionInline(kOSASelectStore, 16);
  553.     
  554.         Errors*:
  555.             badComponentInstance    invalid scripting component instance
  556.             errOSASystemError
  557.             errOSAInvalidID
  558.             errOSABadStorageType*:    desiredType not for this scripting component
  559.         
  560.         ModeFlags*:
  561.             kOSAModePreventGetSource
  562.             kOSAModeDontStoreParent
  563.     *)
  564. (* Executing Scripts*: *)
  565. PROCEDURE OSAExecute*(scriptingComponent: Components.ComponentInstance; compiledScriptID: OSAID; contextID: OSAID; modeFlags: LONGINT; VAR resultingScriptValueID: OSAID): OSAError;
  566.     (*$IF NOT GENERATINGCFM*)
  567.     INLINE PASCAL $2F3C, $10, $0003, $7000, $A82A;
  568.     (*$END*)
  569. (*
  570.         OSAComponentFunctionInline(kOSASelectExecute, 16);
  571.         This call runs a script.  The contextID represents the environment
  572.         with which global variables in the script are resolved.  The constant
  573.         kOSANullScript may be used for the contextID if the application wishes
  574.         to not deal with context directly (a default one is associated with each
  575.         scripting component instance).  The resultingScriptValueID is the 
  576.         result of evaluation, and contains a value which may be displayed using
  577.         the OSAGetSource call.  The modeFlags convey scripting component
  578.         specific information.
  579.     
  580.         Errors*:
  581.             badComponentInstance    invalid scripting component instance
  582.             errOSASystemError
  583.             errOSAInvalidID
  584.             errOSAScriptError*:        the executing script got an error
  585.     
  586.         ModeFlags*:
  587.             kOSAModeNeverInteract
  588.             kOSAModeCanInteract
  589.             kOSAModeAlwaysInteract
  590.             kOSAModeCantSwitchLayer
  591.             kOSAModeDontReconnect
  592.             kOSAModeDoRecord
  593.     *)
  594. (* Displaying results*: *)
  595. PROCEDURE OSADisplay*(scriptingComponent: Components.ComponentInstance; scriptValueID: OSAID; desiredType: AppleEvents.DescType; modeFlags: LONGINT; VAR resultingText: AppleEvents.AEDesc): OSAError;
  596.     (*$IF NOT GENERATINGCFM*)
  597.     INLINE PASCAL $2F3C, $10, $0004, $7000, $A82A;
  598.     (*$END*)
  599. (*
  600.         OSAComponentFunctionInline(kOSASelectDisplay, 16);
  601.         This call is used to convert results (script value IDs) into displayable
  602.         text. The desiredType should be at least typeChar, and modeFlags are
  603.         scripting system specific flags to control the formatting of the
  604.         resulting text. This call differs from OSAGetSource in that (1) it
  605.         always produces at least typeChar, (2) is only works on script values,
  606.         (3) it may display it's output in non-compilable form (e.g. without
  607.         string quotes, elipses inserted in long and/or circular lists, etc.) and
  608.         (4) it is required by the basic scripting interface.
  609.     
  610.         Errors*:
  611.             badComponentInstance    invalid scripting component instance
  612.             errOSASystemError
  613.             errOSAInvalidID
  614.             errAECoercionFail*:        desiredType not supported by scripting component
  615.     
  616.         ModeFlags*:
  617.             kOSAModeDisplayForHumans
  618.     *)
  619. (* Getting Error Information*: *)
  620. PROCEDURE OSAScriptError*(scriptingComponent: Components.ComponentInstance; selector: Types.OSType; desiredType: AppleEvents.DescType; VAR resultingErrorDescription: AppleEvents.AEDesc): OSAError;
  621.     (*$IF NOT GENERATINGCFM*)
  622.     INLINE PASCAL $2F3C, $C, $0005, $7000, $A82A;
  623.     (*$END*)
  624. (*
  625.         OSAComponentFunctionInline(kOSASelectScriptError, 12);
  626.         Whenever script execution returns errOSAExecutionError, this routine
  627.         may be used to get information about that error.  The selector describes
  628.         the type of information desired about the error (various selectors are
  629.         listed below).  The desiredType indicates the data type of the result
  630.         desired for that selector.
  631.     
  632.         Errors*:
  633.             badComponentInstance    invalid scripting component instance
  634.             errOSASystemError
  635.             errOSABadSelector*:        selector not supported by scripting component
  636.             errAECoercionFail*:        desiredType not supported by scripting component
  637.     *)
  638. (* OSAScriptError selectors*: *)
  639. (*
  640.         This selector is used to determine the error number of a script error.
  641.         These error numbers may be either system error numbers, or error numbers
  642.         that are scripting component specific.
  643.         Required desiredTypes*:    
  644.               typeShortInteger
  645.     *)
  646.  
  647. CONST
  648.     kOSAErrorNumber*                = AppleEvents.keyErrorNumber;
  649.  
  650. (*
  651.         This selector is used to determine the full error message associated
  652.         with the error number.  It should include the name of the application
  653.         which caused the error, as well as the specific error that occurred.
  654.         This selector is sufficient for simple error reporting (but see
  655.         kOSAErrorBriefMessage, below).
  656.         Required desiredTypes*:
  657.             typeChar                    error message string
  658.     *)
  659.     kOSAErrorMessage*            = AppleEvents.keyErrorString;
  660.  
  661. (*
  662.         This selector is used to determine a brief error message associated with
  663.         the error number.  This message and should not mention the name of the
  664.         application which caused the error, any partial results or offending
  665.         object (see kOSAErrorApp, kOSAErrorPartialResult and
  666.         kOSAErrorOffendingObject, below).
  667.         Required desiredTypes*:
  668.               typeChar                    brief error message string
  669.     *)
  670. (*  0x65727262  *)
  671.     kOSAErrorBriefMessage*        = LONG("errb");
  672.  
  673. (*
  674.         This selector is used to determine which application actually got the
  675.         error (if it was the result of an AESend), or the current application
  676.         if ....
  677.         Required desiredTypes*:
  678.               typeProcessSerialNumber        PSN of the errant application
  679.               typeChar                    name of the errant application
  680.     *)
  681. (*  0x65726170  *)
  682.     kOSAErrorApp*                = LONG("erap");
  683.  
  684. (*
  685.         This selector is used to determine any partial result returned by an 
  686.         operation. If an AESend call failed, but a partial result was returned,
  687.         then the partial result may be returned as an AppleEvents.AEDesc.
  688.         Required desiredTypes*:
  689.               typeBest                    AppleEvents.AEDesc of any partial result
  690.     *)
  691. (*  0x70746c72   *)
  692.     kOSAErrorPartialResult*        = LONG("ptlr");
  693.  
  694. (*
  695.         This selector is used to determine any object which caused the error
  696.         that may have been indicated by an application.  The result is an 
  697.         AppleEvents.AEDesc.
  698.         Required desiredTypes*:
  699.               typeBest                    AppleEvents.AEDesc of any offending object
  700.     *)
  701. (*  0x65726f62   *)
  702.     kOSAErrorOffendingObject*    = LONG("erob");
  703.  
  704. (*
  705.         This selector is used to determine the type expected by a coercion 
  706.         operation if a type error occurred.
  707.     *)
  708. (*  0x65727274   *)
  709.     kOSAErrorExpectedType*        = LONG("errt");
  710.  
  711. (*
  712.         This selector is used to determine the source text range (start and 
  713.         end positions) of where the error occurred.
  714.         Required desiredTypes*:
  715.               typeOSAErrorRange
  716.     *)
  717. (*  0x65726e67  *)
  718.     kOSAErrorRange*                = LONG("erng");
  719.  
  720. (*
  721.         An AppleEvents.AERecord type containing keyOSASourceStart and keyOSASourceEnd fields
  722.         of type short.
  723.     *)
  724. (*  0x65726e67   *)
  725.     typeOSAErrorRange*            = LONG("erng");
  726.  
  727. (* Field of a typeOSAErrorRange record of typeShortInteger *)
  728. (*  0x73726373    *)
  729.     keyOSASourceStart*            = LONG("srcs");
  730.  
  731. (* Field of a typeOSAErrorRange record of typeShortInteger *)
  732. (*  0x73726365   *)
  733.     keyOSASourceEnd*                = LONG("srce");
  734.  
  735. (* Disposing Script IDs*: *)
  736.  
  737. PROCEDURE OSADispose*(scriptingComponent: Components.ComponentInstance; scriptID: OSAID): OSAError;
  738.     (*$IF NOT GENERATINGCFM*)
  739.     INLINE PASCAL $2F3C, $4, $0006, $7000, $A82A;
  740.     (*$END*)
  741. (*
  742.         OSAComponentFunctionInline(kOSASelectDispose, 4);
  743.         Disposes a script or context.
  744.     
  745.         Errors*:
  746.             badComponentInstance    invalid scripting component instance
  747.             errOSASystemError
  748.             errOSAInvalidID
  749.     *)
  750. (* Getting and Setting Script Information*: *)
  751. PROCEDURE OSASetScriptInfo*(scriptingComponent: Components.ComponentInstance; scriptID: OSAID; selector: Types.OSType; value: LONGINT): OSAError;
  752.     (*$IF NOT GENERATINGCFM*)
  753.     INLINE PASCAL $2F3C, $C, $0007, $7000, $A82A;
  754.     (*$END*)
  755. (*
  756.         OSAComponentFunctionInline(kOSASelectSetScriptInfo, 12);
  757.     
  758.         Errors*:
  759.             badComponentInstance    invalid scripting component instance
  760.             errOSASystemError
  761.             errOSAInvalidID
  762.             errOSABadSelector*:        selector not supported by scripting component
  763.                                     or selector not for this scriptID
  764.     *)
  765. PROCEDURE OSAGetScriptInfo*(scriptingComponent: Components.ComponentInstance; scriptID: OSAID; selector: Types.OSType; VAR result: LONGINT): OSAError;
  766.     (*$IF NOT GENERATINGCFM*)
  767.     INLINE PASCAL $2F3C, $C, $0008, $7000, $A82A;
  768.     (*$END*)
  769. (*
  770.         OSAComponentFunctionInline(kOSASelectGetScriptInfo, 12);
  771.     
  772.         Errors*:
  773.             badComponentInstance    invalid scripting component instance
  774.             errOSASystemError
  775.             errOSAInvalidID
  776.             errOSABadSelector*:        selector not supported by scripting component
  777.                                     or selector not for this scriptID
  778.     *)
  779. (* Manipulating the ActiveProc*:
  780.  
  781.     Scripting systems will supply default values for these procedures if they
  782.     are not set by the client*:
  783. *)
  784. TYPE
  785.     OSAActiveProcPtr* = (*ΔΔ Types.ProcPtr;*) PROCEDURE (refCon: LONGINT): Types.OSErr;
  786.     OSAActiveUPP* = Types.UniversalProcPtr;
  787.  
  788. CONST
  789.     uppOSAActiveProcInfo* = $000000E0; (* PROCEDURE (4 byte param): 2 byte result; *)
  790.  
  791. PROCEDURE NewOSAActiveProc*(userRoutine: OSAActiveProcPtr): OSAActiveUPP;
  792.     (*$IF NOT GENERATINGCFM *)
  793.     INLINE PASCAL $2E9F;
  794.     (*$END*)
  795.  
  796. PROCEDURE CallOSAActiveProc*(refCon: LONGINT; userRoutine: OSAActiveUPP): Types.OSErr;
  797.     (*$IF NOT GENERATINGCFM*)
  798.     INLINE PASCAL $205F, $4E90;
  799.     (*$END*)
  800.  
  801. PROCEDURE OSASetActiveProc*(scriptingComponent: Components.ComponentInstance; activeProc: OSAActiveUPP; refCon: LONGINT): OSAError;
  802.     (*$IF NOT GENERATINGCFM*)
  803.     INLINE PASCAL $2F3C, $8, $0009, $7000, $A82A;
  804.     (*$END*)
  805. (*
  806.         OSAComponentFunctionInline(kOSASelectSetActiveProc, 8);
  807.         If activeProc is nil, the default activeProc is used.
  808.     
  809.         Errors*:
  810.             badComponentInstance    invalid scripting component instance
  811.             errOSASystemError
  812.     *)
  813. PROCEDURE OSAGetActiveProc*(scriptingComponent: Components.ComponentInstance; VAR activeProc: OSAActiveUPP; VAR refCon: LONGINT): OSAError;
  814.     (*$IF NOT GENERATINGCFM*)
  815.     INLINE PASCAL $2F3C, $8, $000A, $7000, $A82A;
  816.     (*$END*)
  817. (*
  818.         OSAComponentFunctionInline(kOSASelectGetActiveProc, 8);
  819.     
  820.         Errors*:
  821.             badComponentInstance    invalid scripting component instance
  822.             errOSASystemError
  823.     *)
  824. (**************************************************************************
  825.     OSA Optional Compiling Interface
  826. **************************************************************************
  827.     Scripting components that support the Compiling interface have the 
  828.     kOSASupportsCompiling bit set in it's Components.ComponentDescription.
  829. **************************************************************************)
  830. PROCEDURE OSAScriptingComponentName*(scriptingComponent: Components.ComponentInstance; VAR resultingScriptingComponentName: AppleEvents.AEDesc): OSAError;
  831.     (*$IF NOT GENERATINGCFM*)
  832.     INLINE PASCAL $2F3C, $4, $0102, $7000, $A82A;
  833.     (*$END*)
  834. (*
  835.         OSAComponentFunctionInline(kOSASelectScriptingComponentName, 4);
  836.         Given a scripting component, this routine returns the name of that
  837.         scripting component in a type that is coercable to text (typeChar).
  838.         The generic scripting component returns the name of the default
  839.         scripting component.  This name should be sufficient to convey to the
  840.         user the kind of script (syntax) he is expected to write.
  841.     
  842.         Errors*:
  843.             badComponentInstance    invalid scripting component instance
  844.             errOSASystemError
  845.     *)
  846. PROCEDURE OSACompile*(scriptingComponent: Components.ComponentInstance; (*CONST*)VAR sourceData: AppleEvents.AEDesc; modeFlags: LONGINT; VAR previousAndResultingScriptID: OSAID): OSAError;
  847.     (*$IF NOT GENERATINGCFM*)
  848.     INLINE PASCAL $2F3C, $C, $0103, $7000, $A82A;
  849.     (*$END*)
  850. (*
  851.         OSAComponentFunctionInline(kOSASelectCompile, 12);
  852.         Coerces input desc (possibly text) into a script's internal format.
  853.         Once compiled, the script is ready to run.  The modeFlags convey
  854.         scripting component specific information.  The previous script AIFF.ID
  855.         (result parameter) is made to refer to the newly compiled script,
  856.         unless it was originally kOSANullScript.  In this case a new script
  857.         AIFF.ID is created and used.
  858.     
  859.         Errors*:
  860.             badComponentInstance    invalid scripting component instance
  861.             errOSASystemError
  862.             errAECoercionFail*:        sourceData is not compilable
  863.             errOSAScriptError*:        sourceData was a bad script (syntax error)
  864.             errOSAInvalidID*:        previousAndResultingCompiledScriptID was not
  865.                                     valid on input
  866.     
  867.         ModeFlags*:
  868.             kOSAModePreventGetSource
  869.             kOSAModeCompileIntoContext
  870.             kOSAModeAugmentContext
  871.             kOSAModeNeverInteract
  872.             kOSAModeCanInteract
  873.             kOSAModeAlwaysInteract
  874.             kOSAModeCantSwitchLayer
  875.             kOSAModeDontReconnect
  876.             kOSAModeDoRecord
  877.     *)
  878. PROCEDURE OSACopyID*(scriptingComponent: Components.ComponentInstance; fromID: OSAID; VAR toID: OSAID): OSAError;
  879.     (*$IF NOT GENERATINGCFM*)
  880.     INLINE PASCAL $2F3C, $8, $0104, $7000, $A82A;
  881.     (*$END*)
  882. (*
  883.         OSAComponentFunctionInline(kOSASelectCopyID, 8);
  884.         If toID is a reference to kOSANullScript then it is updated to have a
  885.         new scriptID value.  This call can be used to perform undo or revert
  886.         operations on scripts. 
  887.     
  888.         Errors*:
  889.             badComponentInstance    invalid scripting component instance
  890.             errOSASystemError
  891.             errOSAInvalidID
  892.     *)
  893. (**************************************************************************
  894.     OSA Optional GetSource Interface
  895. **************************************************************************
  896.     Scripting components that support the GetSource interface have the 
  897.     kOSASupportsGetSource bit set in it's Components.ComponentDescription.
  898. **************************************************************************)
  899. PROCEDURE OSAGetSource*(scriptingComponent: Components.ComponentInstance; scriptID: OSAID; desiredType: AppleEvents.DescType; VAR resultingSourceData: AppleEvents.AEDesc): OSAError;
  900.     (*$IF NOT GENERATINGCFM*)
  901.     INLINE PASCAL $2F3C, $C, $0201, $7000, $A82A;
  902.     (*$END*)
  903. (*
  904.         OSAComponentFunctionInline(kOSASelectGetSource, 12);
  905.         This routine causes a compiled script to be output in a form (possibly
  906.         text) such that it is suitable to be passed back to OSACompile.
  907.  
  908.         Errors*:
  909.             badComponentInstance    invalid scripting component instance
  910.             errOSASystemError
  911.             errOSAInvalidID
  912.             errOSASourceNotAvailable    can't get source for this scriptID
  913.     *)
  914. (**************************************************************************
  915.     OSA Optional AECoercion Interface
  916. **************************************************************************
  917.     Scripting components that support the AECoercion interface have the 
  918.     kOSASupportsAECoercion bit set in it's Components.ComponentDescription.
  919. **************************************************************************)
  920. PROCEDURE OSACoerceFromDesc*(scriptingComponent: Components.ComponentInstance; (*CONST*)VAR scriptData: AppleEvents.AEDesc; modeFlags: LONGINT; VAR resultingScriptID: OSAID): OSAError;
  921.     (*$IF NOT GENERATINGCFM*)
  922.     INLINE PASCAL $2F3C, $C, $0301, $7000, $A82A;
  923.     (*$END*)
  924. (*
  925.         OSAComponentFunctionInline(kOSASelectCoerceFromDesc, 12);
  926.         This routine causes script data to be coerced into a script value.
  927.         If the scriptData is an AppleEvents.AppleEvent, then the resultingScriptID is a
  928.         compiled script AIFF.ID (mode flags for OSACompile may be used in this case).
  929.         Other scriptData descriptors create script value IDs.
  930.     
  931.         Errors*:
  932.             badComponentInstance    invalid scripting component instance
  933.             errOSASystemError
  934.     
  935.         ModeFlags*:
  936.             kOSAModePreventGetSource
  937.             kOSAModeCompileIntoContext
  938.             kOSAModeNeverInteract
  939.             kOSAModeCanInteract
  940.             kOSAModeAlwaysInteract
  941.             kOSAModeCantSwitchLayer
  942.             kOSAModeDontReconnect
  943.             kOSAModeDoRecord
  944.     *)
  945. PROCEDURE OSACoerceToDesc*(scriptingComponent: Components.ComponentInstance; scriptID: OSAID; desiredType: AppleEvents.DescType; modeFlags: LONGINT; VAR result: AppleEvents.AEDesc): OSAError;
  946.     (*$IF NOT GENERATINGCFM*)
  947.     INLINE PASCAL $2F3C, $10, $0302, $7000, $A82A;
  948.     (*$END*)
  949. (*
  950.         OSAComponentFunctionInline(kOSASelectCoerceToDesc, 16);
  951.         This routine causes a script value to be coerced into any desired form.
  952.         If the scriptID denotes a compiled script, then it may be coerced to 
  953.         typeAppleEvent.
  954.     
  955.         Errors*:
  956.             badComponentInstance    invalid scripting component instance
  957.             errOSASystemError
  958.             errOSAInvalidID
  959.     *)
  960. (**************************************************************************
  961.     OSA Optional AESending Interface
  962. **************************************************************************
  963.     Scripting components that support the AESending interface have the 
  964.     kOSASupportsAESending bit set in it's Components.ComponentDescription.
  965. **************************************************************************)
  966. (*
  967.     Scripting systems will supply default values for these procedures if they
  968.     are not set by the client*:
  969. *)
  970. PROCEDURE OSASetSendProc*(scriptingComponent: Components.ComponentInstance; sendProc: OSASendUPP; refCon: LONGINT): OSAError;
  971.     (*$IF NOT GENERATINGCFM*)
  972.     INLINE PASCAL $2F3C, $8, $0401, $7000, $A82A;
  973.     (*$END*)
  974. (*
  975.         OSAComponentFunctionInline(kOSASelectSetSendProc, 8);
  976.         If sendProc is nil, the default sendProc is used.
  977.     
  978.         Errors*:
  979.             badComponentInstance    invalid scripting component instance
  980.             errOSASystemError
  981.     *)
  982. PROCEDURE OSAGetSendProc*(scriptingComponent: Components.ComponentInstance; VAR sendProc: OSASendUPP; VAR refCon: LONGINT): OSAError;
  983.     (*$IF NOT GENERATINGCFM*)
  984.     INLINE PASCAL $2F3C, $8, $0402, $7000, $A82A;
  985.     (*$END*)
  986. (*
  987.         OSAComponentFunctionInline(kOSASelectGetSendProc, 8);
  988.     
  989.         Errors*:
  990.             badComponentInstance    invalid scripting component instance
  991.             errOSASystemError
  992.     *)
  993. PROCEDURE OSASetCreateProc*(scriptingComponent: Components.ComponentInstance; createProc: OSACreateAppleEventUPP; refCon: LONGINT): OSAError;
  994.     (*$IF NOT GENERATINGCFM*)
  995.     INLINE PASCAL $2F3C, $8, $0403, $7000, $A82A;
  996.     (*$END*)
  997. (*
  998.         OSAComponentFunctionInline(kOSASelectSetCreateProc, 8);
  999.         If createProc is nil, the default createProc is used.
  1000.     
  1001.         Errors*:
  1002.             badComponentInstance    invalid scripting component instance
  1003.             errOSASystemError
  1004.     *)
  1005. PROCEDURE OSAGetCreateProc*(scriptingComponent: Components.ComponentInstance; VAR createProc: OSACreateAppleEventUPP; VAR refCon: LONGINT): OSAError;
  1006.     (*$IF NOT GENERATINGCFM*)
  1007.     INLINE PASCAL $2F3C, $8, $0404, $7000, $A82A;
  1008.     (*$END*)
  1009. (*
  1010.         OSAComponentFunctionInline(kOSASelectGetCreateProc, 8);
  1011.     
  1012.         Errors*:
  1013.             badComponentInstance    invalid scripting component instance
  1014.             errOSASystemError
  1015.     *)
  1016. PROCEDURE OSASetDefaultTarget*(scriptingComponent: Components.ComponentInstance; (*CONST*)VAR target: AppleEvents.AEAddressDesc): OSAError;
  1017.     (*$IF NOT GENERATINGCFM*)
  1018.     INLINE PASCAL $2F3C, $4, $0405, $7000, $A82A;
  1019.     (*$END*)
  1020. (*
  1021.         OSAComponentFunctionInline(kOSASelectSetDefaultTarget, 4);
  1022.         This routine sets the default target application for AE sending.
  1023.         It also establishes the default target from which terminologies come.
  1024.         It is effectively like having an AppleScript "tell" statement around
  1025.         the entire program.  If this routine is not called, or if the target 
  1026.         is a null AppleEvents.AEDesc, then the current application is the default target.
  1027.     
  1028.         Errors*:
  1029.             badComponentInstance    invalid scripting component instance
  1030.             errOSASystemError
  1031.     *)
  1032. (**************************************************************************
  1033.     OSA Optional Recording Interface
  1034. **************************************************************************
  1035.     Scripting components that support the Recording interface have the 
  1036.     kOSASupportsRecording bit set in it's Components.ComponentDescription.
  1037. **************************************************************************)
  1038. PROCEDURE OSAStartRecording*(scriptingComponent: Components.ComponentInstance; VAR compiledScriptToModifyID: OSAID): OSAError;
  1039.     (*$IF NOT GENERATINGCFM*)
  1040.     INLINE PASCAL $2F3C, $4, $0501, $7000, $A82A;
  1041.     (*$END*)
  1042. (*
  1043.         OSAComponentFunctionInline(kOSASelectStartRecording, 4);
  1044.         Starts recording.  If compiledScriptToModifyID is kOSANullScript, a
  1045.         new script AIFF.ID is created and returned.  If the current application has
  1046.         a handler for the kOSARecordedText event, then kOSARecordedText events
  1047.         are sent to the application containing the text of each AppleEvents.AppleEvent 
  1048.         recorded.
  1049.     
  1050.         Errors*:
  1051.             badComponentInstance    invalid scripting component instance
  1052.             errOSASystemError
  1053.             errOSAInvalidID
  1054.             errOSARecordingIsAlreadyOn
  1055.     *)
  1056. PROCEDURE OSAStopRecording*(scriptingComponent: Components.ComponentInstance; compiledScriptID: OSAID): OSAError;
  1057.     (*$IF NOT GENERATINGCFM*)
  1058.     INLINE PASCAL $2F3C, $4, $0502, $7000, $A82A;
  1059.     (*$END*)
  1060. (*
  1061.         OSAComponentFunctionInline(kOSASelectStopRecording, 4);
  1062.         If compiledScriptID is not being recorded into or recording is not
  1063.         currently on, no error is returned.
  1064.     
  1065.         Errors*:
  1066.             badComponentInstance    invalid scripting component instance
  1067.             errOSASystemError
  1068.             errOSAInvalidID
  1069.     *)
  1070. (**************************************************************************
  1071.     OSA Optional Convenience Interface
  1072. **************************************************************************
  1073.     Scripting components that support the Convenience interface have the 
  1074.     kOSASupportsConvenience bit set in it's Components.ComponentDescription.
  1075. **************************************************************************)
  1076. PROCEDURE OSALoadExecute*(scriptingComponent: Components.ComponentInstance; (*CONST*)VAR scriptData: AppleEvents.AEDesc; contextID: OSAID; modeFlags: LONGINT; VAR resultingScriptValueID: OSAID): OSAError;
  1077.     (*$IF NOT GENERATINGCFM*)
  1078.     INLINE PASCAL $2F3C, $10, $0601, $7000, $A82A;
  1079.     (*$END*)
  1080. (*
  1081.         OSAComponentFunctionInline(kOSASelectLoadExecute, 16);
  1082.         This routine is effectively equivalent to calling OSALoad followed by
  1083.         OSAExecute.  After execution, the compiled source is disposed.  Only the
  1084.         resulting value AIFF.ID is retained.
  1085.     
  1086.         Errors*:
  1087.             badComponentInstance        invalid scripting component instance
  1088.             errOSASystemError
  1089.             errOSABadStorageType*:        scriptData not for this scripting component
  1090.             errOSACorruptData*:            data seems to be corrupt
  1091.             errOSADataFormatObsolete    script data format is no longer supported
  1092.             errOSADataFormatTooNew        script data format is from a newer version
  1093.             errOSAInvalidID
  1094.             errOSAScriptError*:            the executing script got an error
  1095.     
  1096.         ModeFlags*:
  1097.             kOSAModeNeverInteract
  1098.             kOSAModeCanInteract
  1099.             kOSAModeAlwaysInteract
  1100.             kOSAModeCantSwitchLayer
  1101.             kOSAModeDontReconnect
  1102.             kOSAModeDoRecord
  1103.     *)
  1104. PROCEDURE OSACompileExecute*(scriptingComponent: Components.ComponentInstance; (*CONST*)VAR sourceData: AppleEvents.AEDesc; contextID: OSAID; modeFlags: LONGINT; VAR resultingScriptValueID: OSAID): OSAError;
  1105.     (*$IF NOT GENERATINGCFM*)
  1106.     INLINE PASCAL $2F3C, $10, $0602, $7000, $A82A;
  1107.     (*$END*)
  1108. (*
  1109.         OSAComponentFunctionInline(kOSASelectCompileExecute, 16);
  1110.         This routine is effectively equivalent to calling OSACompile followed by
  1111.         OSAExecute.  After execution, the compiled source is disposed.  Only the
  1112.         resulting value AIFF.ID is retained.
  1113.     
  1114.         Errors*:
  1115.             badComponentInstance    invalid scripting component instance
  1116.             errOSASystemError
  1117.             errAECoercionFail*:        sourceData is not compilable
  1118.             errOSAScriptError*:        sourceData was a bad script (syntax error)
  1119.             errOSAInvalidID*:        previousAndResultingCompiledScriptID was not
  1120.                                     valid on input
  1121.             errOSAScriptError*:        the executing script got an error
  1122.     
  1123.         ModeFlags*:
  1124.             kOSAModeNeverInteract
  1125.             kOSAModeCanInteract
  1126.             kOSAModeAlwaysInteract
  1127.             kOSAModeCantSwitchLayer
  1128.             kOSAModeDontReconnect
  1129.             kOSAModeDoRecord
  1130.     *)
  1131. PROCEDURE OSADoScript*(scriptingComponent: Components.ComponentInstance; (*CONST*)VAR sourceData: AppleEvents.AEDesc; contextID: OSAID; desiredType: AppleEvents.DescType; modeFlags: LONGINT; VAR resultingText: AppleEvents.AEDesc): OSAError;
  1132.     (*$IF NOT GENERATINGCFM*)
  1133.     INLINE PASCAL $2F3C, $14, $0603, $7000, $A82A;
  1134.     (*$END*)
  1135. (*
  1136.         OSAComponentFunctionInline(kOSASelectDoScript, 20);
  1137.         This routine is effectively equivalent to calling OSACompile followed by
  1138.         OSAExecute and then OSADisplay.  After execution, the compiled source
  1139.         and the resulting value are is disposed.  Only the resultingText
  1140.         descriptor is retained.  If a script error occur during processing, the 
  1141.         resultingText gets the error message of the error, and errOSAScriptError
  1142.         is returned.  OSAScriptError may still be used to extract more 
  1143.         information about the particular error.
  1144.     
  1145.         Errors*:
  1146.             badComponentInstance    invalid scripting component instance
  1147.             errOSASystemError
  1148.             errAECoercionFail*:        sourceData is not compilable or 
  1149.                                     desiredType not supported by scripting component
  1150.             errOSAScriptError*:        sourceData was a bad script (syntax error)
  1151.             errOSAInvalidID*:        previousAndResultingCompiledScriptID was not
  1152.                                     valid on input
  1153.             errOSAScriptError*:        the executing script got an error
  1154.     
  1155.         ModeFlags*:
  1156.             kOSAModeNeverInteract
  1157.             kOSAModeCanInteract
  1158.             kOSAModeAlwaysInteract
  1159.             kOSAModeCantSwitchLayer
  1160.             kOSAModeDontReconnect
  1161.             kOSAModeDoRecord
  1162.             kOSAModeDisplayForHumans
  1163.     *)
  1164. (**************************************************************************
  1165.     OSA Optional Dialects Interface
  1166. **************************************************************************
  1167.     Scripting components that support the Dialects interface have the 
  1168.     kOSASupportsDialects bit set in it's Components.ComponentDescription.
  1169. **************************************************************************)
  1170. (*
  1171.     These calls allows an scripting component that supports different dialects
  1172.     to dynamically switch between those dialects.  Although this interface is
  1173.     specified, the particular dialect codes are scripting component dependent.
  1174. *)
  1175. PROCEDURE OSASetCurrentDialect*(scriptingComponent: Components.ComponentInstance; dialectCode: INTEGER): OSAError;
  1176.     (*$IF NOT GENERATINGCFM*)
  1177.     INLINE PASCAL $2F3C, $2, $0701, $7000, $A82A;
  1178.     (*$END*)
  1179. (*
  1180.         OSAComponentFunctionInline(kOSASelectSetCurrentDialect, 2);
  1181.     
  1182.         Errors*:
  1183.             badComponentInstance    invalid scripting component instance
  1184.             errOSASystemError
  1185.             errOSANoSuchDialect*:    invalid dialectCode
  1186.     *)
  1187. PROCEDURE OSAGetCurrentDialect*(scriptingComponent: Components.ComponentInstance; VAR resultingDialectCode: INTEGER): OSAError;
  1188.     (*$IF NOT GENERATINGCFM*)
  1189.     INLINE PASCAL $2F3C, $4, $0702, $7000, $A82A;
  1190.     (*$END*)
  1191. (*
  1192.         OSAComponentFunctionInline(kOSASelectGetCurrentDialect, 4);
  1193.     
  1194.         Errors*:
  1195.             badComponentInstance    invalid scripting component instance
  1196.             errOSASystemError
  1197.     *)
  1198. PROCEDURE OSAAvailableDialects*(scriptingComponent: Components.ComponentInstance; VAR resultingDialectInfoList: AppleEvents.AEDesc): OSAError;
  1199.     (*$IF NOT GENERATINGCFM*)
  1200.     INLINE PASCAL $2F3C, $4, $0703, $7000, $A82A;
  1201.     (*$END*)
  1202. (*
  1203.         OSAComponentFunctionInline(kOSASelectAvailableDialects, 4);
  1204.         This call return an AEList containing information about each of the
  1205.         currently available dialects of a scripting component.  Each item
  1206.         is an AppleEvents.AERecord of typeOSADialectInfo that contains at least the fields
  1207.         keyOSADialectName, keyOSADialectCode, KeyOSADialectLangCode and 
  1208.         keyOSADialectScriptCode.
  1209.     
  1210.         Errors*:
  1211.             badComponentInstance    invalid scripting component instance
  1212.             errOSASystemError
  1213.     *)
  1214. PROCEDURE OSAGetDialectInfo*(scriptingComponent: Components.ComponentInstance; dialectCode: INTEGER; selector: Types.OSType; VAR resultingDialectInfo: AppleEvents.AEDesc): OSAError;
  1215.     (*$IF NOT GENERATINGCFM*)
  1216.     INLINE PASCAL $2F3C, $A, $0704, $7000, $A82A;
  1217.     (*$END*)
  1218. (*
  1219.         OSAComponentFunctionInline(kOSASelectGetDialectInfo, 10);
  1220.         This call gives information about the specified dialect of a scripting
  1221.         component. It returns an AppleEvents.AEDesc whose type depends on the selector 
  1222.         specified. Available selectors are the same as the field keys for a
  1223.         dialect info record. The type of AppleEvents.AEDesc returned is the same as the 
  1224.         type of the field that has same key as the selector.
  1225.     
  1226.         Errors*:
  1227.             badComponentInstance    invalid scripting component instance
  1228.             errOSASystemError
  1229.              errOSABadSelector
  1230.             errOSANoSuchDialect*:    invalid dialectCode
  1231.     *)
  1232. PROCEDURE OSAAvailableDialectCodeList*(scriptingComponent: Components.ComponentInstance; VAR resultingDialectCodeList: AppleEvents.AEDesc): OSAError;
  1233.     (*$IF NOT GENERATINGCFM*)
  1234.     INLINE PASCAL $2F3C, $4, $0705, $7000, $A82A;
  1235.     (*$END*)
  1236. (*
  1237.         OSAComponentFunctionInline(kOSASelectAvailableDialectCodeList, 4);
  1238.         This is alternative to OSAGetAvailableDialectCodeList. Use this call
  1239.         and  OSAGetDialectInfo to get information on dialects.
  1240.         This call return an AEList containing dialect code for each of the
  1241.         currently available dialects of a scripting component. Each dialect
  1242.         code is a short integer of type typeShortInteger.
  1243.     
  1244.         Errors*:
  1245.             badComponentInstance    invalid scripting component instance
  1246.             errOSASystemError
  1247.  
  1248.         Type of a dialect info record containing at least keyOSADialectName
  1249.         and keyOSADialectCode fields.
  1250.  
  1251.         keys for dialect info record, also used as selectors to OSAGetDialectInfo.
  1252.  
  1253.         Field of a typeOSADialectInfo record of typeChar.
  1254.         Field of a typeOSADialectInfo record of typeShortInteger.
  1255.         Field of a typeOSADialectInfo record of typeShortInteger.
  1256.         Field of a typeOSADialectInfo record of typeShortInteger.
  1257.     *)
  1258. (**************************************************************************
  1259.     OSA Optional Event Handling Interface
  1260. **************************************************************************
  1261.     Scripting components that support the Event Handling interface have the 
  1262.     kOSASupportsEventHandling bit set in it's Components.ComponentDescription.
  1263. **************************************************************************)
  1264. PROCEDURE OSASetResumeDispatchProc*(scriptingComponent: Components.ComponentInstance; resumeDispatchProc: AppleEvents.AEEventHandlerUPP; refCon: LONGINT): OSAError;
  1265.     (*$IF NOT GENERATINGCFM*)
  1266.     INLINE PASCAL $2F3C, $8, $0801, $7000, $A82A;
  1267.     (*$END*)
  1268. (*
  1269.         OSAComponentFunctionInline(kOSASelectSetResumeDispatchProc, 8);
  1270.         This function is used to set the ResumeDispatchProc that will be used
  1271.         by OSAExecuteEvent and OSADoEvent if either no event handler can be
  1272.         found in the context, or the context event hander "continues" control
  1273.         onward. The two constants kOSAUseStandardDispatch and kOSANoDispatch
  1274.         may also be passed to this routine indicating that the handler registered
  1275.         in the application with AEInstallEventHandler should be used, or no
  1276.         dispatch should occur, respectively.
  1277.     
  1278.         Errors*:
  1279.             badComponentInstance    invalid scripting component instance
  1280.             errOSASystemError
  1281.     *)
  1282.  
  1283. CONST
  1284.     kOSAUseStandardDispatch*        = AppleEvents.kAEUseStandardDispatch;
  1285.  
  1286. (*
  1287.         Special ResumeDispatchProc constant which may be passed to 
  1288.         OSASetResumeDispatchProc indicating that the handler registered
  1289.         in the application with AEInstallEventHandler should be used.
  1290.         
  1291.         NOTE*:    Had to remove the cast (AEEventHandlerUPP).  The C compiler
  1292.                 doesn't allow pointer types to be assigned to an enum.  All
  1293.                 constants must be assigned as enums to translate properly to
  1294.                 Pascal.
  1295.     *)
  1296.     kOSANoDispatch*                = AppleEvents.kAENoDispatch;
  1297.  
  1298. (*
  1299.         Special ResumeDispatchProc constant which may be passed to 
  1300.         OSASetResumeDispatchProc indicating that no dispatch should occur.
  1301.         
  1302.         NOTE*:    Had to remove the cast (AEEventHandlerUPP).  The C compiler
  1303.                 doesn't allow pointer types to be assigned to an enum.  All
  1304.                 constants must be assigned as enums to translate properly to
  1305.                 Pascal.
  1306.     *)
  1307.     kOSADontUsePhac*                = $0001;
  1308.  
  1309. (*
  1310.         Special refCon constant that may be given to OSASetResumeDispatchProc
  1311.         only when kOSAUseStandardDispatch is used as the ResumeDispatchProc.
  1312.         This causes the standard dispatch to be performed, except the phac
  1313.         handler is not called.  This is useful during tinkerability, when
  1314.         the phac handler is used to lookup a context associated with an event's 
  1315.         direct parameter, and call OSAExecuteEvent or OSADoEvent.  Failure to
  1316.         bypass the phac handler would result in an infinite loop.
  1317.     *)
  1318.  
  1319. PROCEDURE OSAGetResumeDispatchProc*(scriptingComponent: Components.ComponentInstance; VAR resumeDispatchProc: AppleEvents.AEEventHandlerUPP; VAR refCon: LONGINT): OSAError;
  1320.     (*$IF NOT GENERATINGCFM*)
  1321.     INLINE PASCAL $2F3C, $8, $0802, $7000, $A82A;
  1322.     (*$END*)
  1323. (*
  1324.         OSAComponentFunctionInline(kOSASelectGetResumeDispatchProc, 8);
  1325.         Returns the registered ResumeDispatchProc.  If no ResumeDispatchProc has
  1326.         been registered, then kOSAUseStandardDispatch (the default) is returned.
  1327.     
  1328.         Errors*:
  1329.             badComponentInstance    invalid scripting component instance
  1330.             errOSASystemError
  1331.     *)
  1332. PROCEDURE OSAExecuteEvent*(scriptingComponent: Components.ComponentInstance; (*CONST*)VAR theAppleEvent: AppleEvents.AppleEvent; contextID: OSAID; modeFlags: LONGINT; VAR resultingScriptValueID: OSAID): OSAError;
  1333.     (*$IF NOT GENERATINGCFM*)
  1334.     INLINE PASCAL $2F3C, $10, $0803, $7000, $A82A;
  1335.     (*$END*)
  1336. (*
  1337.         OSAComponentFunctionInline(kOSASelectExecuteEvent, 16);
  1338.         This call is similar to OSAExecute except the initial command to
  1339.         execute comes in the form of an AppleEvents.AppleEvent.  If the contextID
  1340.         defines any event handlers for that event, they are used to process
  1341.         the event.  If no event handler can be found in the context
  1342.         errAEEventNotHandled is returned.  If an event handler is found and
  1343.         the hander "continues" control onward, the ResumeDispatchProc
  1344.         (registered with OSASetResumeDispatchProc, above) is called given the
  1345.         AppleEvents.AppleEvent.  The result is returned as a scriptValueID.
  1346.     
  1347.         Errors*:
  1348.             badComponentInstance    invalid scripting component instance
  1349.             errOSASystemError
  1350.             errOSAInvalidID
  1351.             errOSAScriptError*:        the executing script got an error
  1352.             errAEEventNotHandled*:    no handler for event in contextID
  1353.     
  1354.         ModeFlags*:
  1355.             kOSAModeNeverInteract
  1356.             kOSAModeCanInteract
  1357.             kOSAModeAlwaysInteract
  1358.             kOSAModeCantSwitchLayer
  1359.             kOSAModeDontReconnect
  1360.             kOSAModeDoRecord
  1361.     *)
  1362. PROCEDURE OSADoEvent*(scriptingComponent: Components.ComponentInstance; (*CONST*)VAR theAppleEvent: AppleEvents.AppleEvent; contextID: OSAID; modeFlags: LONGINT; VAR reply: AppleEvents.AppleEvent): OSAError;
  1363.     (*$IF NOT GENERATINGCFM*)
  1364.     INLINE PASCAL $2F3C, $10, $0804, $7000, $A82A;
  1365.     (*$END*)
  1366. (*
  1367.         OSAComponentFunctionInline(kOSASelectDoEvent, 16);
  1368.         This call is similar to OSADoScript except the initial command to
  1369.         execute comes in the form of an AppleEvents.AppleEvent, and the result is an 
  1370.         AppleEvents.AppleEvent reply record.  If the contextID defines any event handlers
  1371.         for that event, they are used to process the event.  If no event handler
  1372.         can be found in the context errAEEventNotHandled is returned.  If an
  1373.         event handler is found and the hander "continues" control onward, the
  1374.         ResumeDispatchProc (registered with OSASetResumeDispatchProc, above) is
  1375.         called given the AppleEvents.AppleEvent.  The result is returned in the form of an
  1376.         AppleEvents.AppleEvent reply descriptor. If at any time the script gets an error, or
  1377.         if the ResumeDispatchProc returns a reply event indicating an error,
  1378.         then the OSADoEvent call itself returns an error reply (i.e. OSADoEvent
  1379.         should never return errOSAScriptError).  Any error result returned by
  1380.         the ResumeDispatchProc will be returned by OSADoEvent.
  1381.     
  1382.         Errors*:
  1383.             badComponentInstance    invalid scripting component instance
  1384.             errOSASystemError
  1385.             errOSAInvalidID
  1386.             errAEEventNotHandled*:    no handler for event in contextID
  1387.     
  1388.         ModeFlags*:
  1389.             kOSAModeNeverInteract
  1390.             kOSAModeCanInteract
  1391.             kOSAModeAlwaysInteract
  1392.             kOSAModeCantSwitchLayer
  1393.             kOSAModeDontReconnect
  1394.             kOSAModeDoRecord
  1395.     *)
  1396. PROCEDURE OSAMakeContext*(scriptingComponent: Components.ComponentInstance; (*CONST*)VAR contextName: AppleEvents.AEDesc; parentContext: OSAID; VAR resultingContextID: OSAID): OSAError;
  1397.     (*$IF NOT GENERATINGCFM*)
  1398.     INLINE PASCAL $2F3C, $C, $0805, $7000, $A82A;
  1399.     (*$END*)
  1400. (*
  1401.         OSAComponentFunctionInline(kOSASelectMakeContext, 12);
  1402.         Makes a new empty context which may be passed to OSAExecute or 
  1403.         OSAExecuteEvent.  If contextName is typeNull, an unnamed context is
  1404.         created. If parentContext is kOSANullScript then the resulting context
  1405.         does not inherit bindings from any other context.
  1406.     
  1407.         Errors*:
  1408.             badComponentInstance    invalid scripting component instance
  1409.             errOSASystemError
  1410.             errOSAInvalidID
  1411.             errAECoercionFail*:        contextName is invalid
  1412.     *)
  1413.  
  1414. (* $ALIGN RESET*)
  1415. (* $POP*)
  1416.  
  1417.  END OSA.
  1418.